<?php
class Bcms_Auth_Adapter{	protected $_adapter;	protected $_auth;	protected $_authResult;	protected $_hashAlgorithm		= 'sha384';	protected $_tableName			= 'cms_users_accounts';	protected $_identityColumn		= 'username';	protected $_credentialColumn	= 'password';		public function __construct()	{		$this->_adapter = new Zend_Auth_Adapter_DbTable( Zend_Registry::get('db') );		$this->_auth	= Zend_Auth::getInstance();				$this->_adapter->setTableName($this->_tableName);		$this->_adapter->setIdentityColumn($this->_identityColumn);		$this->_adapter->setCredentialColumn($this->_credentialColumn);	}		public function authenticate()	{		$this->_authResult = $this->_auth->authenticate( $this->_adapter );	}		public function getHash($data)	{
		print hash( $this->_hashAlgorithm, $data);		return hash( $this->_hashAlgorithm, $data );	}		public function isValid()	{		return $this->_authResult->isValid();	}		public function setCredential($credential)	{		$this->_adapter->setCredential( $this->getHash($credential) );	}		public function setIdentity($identity)	{		$this->_adapter->setIdentity( $identity );	}		public function writeStorage()	{		$this->_auth->getStorage()->write( $this->_adapter->getResultRowObject(null, $this->_credentialColumn) );	}}
